﻿using System;
using System.Text;

namespace WpfClient.FunctionFileParsing
{
    public class FunctionNameStateHandler : FunctionFileParsingStateHandlerBase
    {
        private readonly StringBuilder functionNameBuilder;

        public FunctionNameStateHandler(FunctionFileParserContext context)
            : base(context)
        {
            functionNameBuilder = new StringBuilder();
        }

        protected override FunctionFileParsingState Handle(char symbol)
        {
            if (symbol == '"')
            {
                this.ParserContext.Result.FunctionName = this.functionNameBuilder.ToString();
                this.functionNameBuilder.Clear();

                return FunctionFileParsingState.Indifferent;
            }

            functionNameBuilder.Append(symbol);

            return FunctionFileParsingState.FunctionName;
        }
    }
}
